package com.hyh.shiyanshiguanli.mapper;

import com.hyh.shiyanshiguanli.domain.dto.AdminAddDTO;
import com.hyh.shiyanshiguanli.domain.dto.AdminUpdateDTO;
import com.hyh.shiyanshiguanli.domain.entity.Admin;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @author hyh
 * @version 1.0
 */
@Mapper
public interface AdminMapper {

    /**
     * 根据用户名查询admin
     * @param username
     * @return
     */
    @Select("SELECT * from admin where username = #{username}")
    Admin selectByUserName(@Param("username") String username);

    /**
     * 根据id查询管理员
     * @return
     */
    @Select("select * from admin where id = #{id}")
    Admin selectById(@Param("id") Integer Id);

    List<Admin> page();

    @Insert("insert into  admin (username, password, image)" +
            "values (#{username},#{password},#{image})")
    void add(AdminAddDTO adminAddDTO);

    void updateById(AdminUpdateDTO adminUpdateDTO);

    @Delete("delete from admin where id = #{id}")
    void deleteById(@Param("id") Integer id);

}
